let targetTime, times, ids, timeHours, timeSeconds, timeMinutes;

init();
function init() {
  timeHours = document.querySelector(".time_hours");
  timeMinutes = document.querySelector(".time_minutes");
  timeSeconds = document.querySelector(".time_seconds");
  times = document.getElementById("times");
  let date = new Date();
  date.setHours(date.getHours() + 10);
  targetTime = date.getTime();
  ids = setInterval(animation, 16);
}

function animation() {
  let date = new Date();
  let time = date.getTime();
  time = Math.round((targetTime - time) / 1000);
  let hours = Math.floor(time / 3600);
  let minutes = Math.floor((time % 3600) / 60);
  let seconds = time - hours * 3600 - minutes * 60;
  timeHours.textContent = hours < 10 ? "0" + hours : hours;
  timeMinutes.textContent = minutes < 10 ? "0" + minutes : minutes;
  timeSeconds.textContent = seconds < 10 ? "0" + seconds : seconds;
  if (hours + minutes + seconds === 0) {
    clearInterval(ids);
  }
}
